﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Castle.Core.Internal;
using Coldairarrow.Business.Goods;
using Coldairarrow.Entity.Base_Company;
using Coldairarrow.IBusiness.Company;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;

namespace Coldairarrow.Api.Controllers.backstage
{
    [Route("/backstage/[controller]/[action]")]
    public class BKS_PartnerController : BaseApiController
    {
        #region DI

        public BKS_PartnerController(IBTB_PartnerBusiness iBTB_PartnerBusiness)
        {
            _iBTB_PartnerBusiness = iBTB_PartnerBusiness;
        }

        IBTB_PartnerBusiness _iBTB_PartnerBusiness { get; }

        #endregion
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<PageResult<BTB_Partner>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _iBTB_PartnerBusiness.GetDataListAsync(input);
        }
        /// <summary>
        /// 添加或修改轮播图
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task SaveData(BTB_Partner data)
        {
            if (data.id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _iBTB_PartnerBusiness.AddDataAsync(data);
            }
            else
            {
                await _iBTB_PartnerBusiness.UpdateDataAsync(data);
            }
        }
        /// <summary>
        /// 删除指定轮播图
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _iBTB_PartnerBusiness.DeleteDataAsync(ids);
        }
    }
}
